/**  
* @Title: MtonsNewsVO.java
* @Package cn.net.mtons.weixin.reply.vo
* @Description: TODO
* @author ma jinjian  
* @date 2016年2月7日 下午5:20:08
* @version V1.0  
*/ 
package cn.net.mtons.weixin.rpl.vo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.net.mtons.weixin.MtonsBasicVO;
import cn.net.mtons.weixin.utils.MtonsMessageUtil;

/**
 * @ClassName: MtonsNewsVO
 * @Description: TODO
 * @author ma jinjian
 * @date 2016年2月7日 下午5:20:08
 *
 */
public class MtonsNewsVO extends MtonsBasicVO {

	private String msgType;
	
	private int articleCount;
	
	private List<Map<String, String>> articles;

	public String getMsgType() {
		return msgType;
	}

	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}

	public int getArticleCount() {
		return articleCount;
	}

	public void setArticleCount(int articleCount) {
		this.articleCount = articleCount;
	}

	public List<Map<String, String>> getArticles() {
		return articles;
	}

	public void setArticles(List<Map<String, String>> articles) {
		this.articles = articles;
	}

	@Override
	public String toXml() {
		MtonsMessageUtil util = new MtonsMessageUtil();
		for(Map<String, String> map : this.getArticles()){
			util.addData("item", map);
		}
		util.surroundWith("Articles");
		MtonsMessageUtil util2 = new MtonsMessageUtil(super.toXml());
		util2.append(util.toString());
		util2.addData("MsgType", "news");
		util2.addData("ArticleCount", this.getArticleCount());
		util2.surroundWith("xml");
		return util2.toString();
	}
	
	public static void main(String[] args) {
		Map<String, String> map1 = new HashMap<String, String>();
		map1.put("Title", "我爱你");
		map1.put("Description", "我爱你");
		map1.put("PicUrl", "图片链接");
		map1.put("Url", "图文链接");
		Map<String, String> map2 = new HashMap<String, String>();
		map2.put("Title", "我爱你");
		map2.put("Description", "我爱你");
		map2.put("PicUrl", "图片链接");
		map2.put("Url", "图文链接");
		List<Map<String, String>> list = new ArrayList<Map<String, String>>();
		list.add(map1);
		list.add(map2);
		MtonsNewsVO vo = new MtonsNewsVO();
		vo.setFromUserName("majinjian");
		vo.setToUserName("liujiao");
		vo.setArticleCount(list.size());
		vo.setArticles(list);
		System.out.println(vo.toXml());
	}
}
